package cn.ffcs.uec.payroll.action;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.ForwardEvent;

import cn.ffcs.raptornuke.plugin.common.zk.ctrl.BasePortletComposer;
import cn.ffcs.raptornuke.portal.theme.ThemeDisplay;
import cn.ffcs.uec.payroll.action.bean.UecPayRollMainBean;
import cn.ffcs.uec.payroll.model.UecPayRoll;
import cn.ffcs.uec.staff.constant.UecStaffConstants;
import cn.ffcs.uom.common.util.IPortletInfoProvider;
import cn.ffcs.uom.common.util.UomZkUtil;

@Controller
@Scope("prototype")
public class UecPayRollMainComposer extends BasePortletComposer implements
		IPortletInfoProvider {

	private static final long serialVersionUID = -5929030282722775845L;

	private UecPayRollMainBean bean = new UecPayRollMainBean();

	private UecPayRoll uecPayRoll;
	
	@Override
	public String getPortletId() {
		return super.getPortletId();
	}

	@Override
	public ThemeDisplay getThemeDisplay() {
		return super.getThemeDisplay();
	}

	@Override
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
		UomZkUtil.autoFitHeight(comp);// 使用<borderlayout>时，需要加上这句进行初始化，不然从仓库调出的页面，不能显示
		Components.wireVariables(comp, bean);
		bean.getUecPayRollboxExt().setPortletInfoProvider(this);
		bean.getUecPayRollboxExt().addForward(
				UecStaffConstants.ON_UEC_STAFF_INFO_QUERY, comp,
				UecStaffConstants.ON_UEC_STAFF_INFO_QUERY_RESPONSE);

		bean.getUecPayRollboxExt().addForward(
				UecStaffConstants.ON_CLEAN_TAB_UEC_STAFF_INFO_QUERY, comp,
				UecStaffConstants.ON_CLEAN_TAB_UEC_STAFF_INFO_QUERY_RESPONSE);
	}

	/**
	 * 界面初始化
	 */
	public void onCreate$uecPayRollMainWin() {

	}

	/**
	 * 
	 * @param event
	 */
	public void onUecPayRollQueryResponse(final ForwardEvent event) {
		uecPayRoll = (UecPayRoll) event.getOrigin().getData();
		if(uecPayRoll != null){
			Events.postEvent(UecStaffConstants.ON_UEC_ENC_QUERY,
					this.bean.getUecPayRollboxExt(), uecPayRoll);
		}
	}



}
